import Vue from 'vue'
import VueRouter from 'vue-router'
import DashView from '../views/DashView.vue'
// import store from '../store'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'dash',
    component: DashView,
    meta:{
      auth:true
    },
    children:[
      {
        path: '',
        name: 'general',
        component: () => import('../views/GeneralView.vue'),//概况
        meta:{
          auth:true
        }
      },
      {
        path: 'storeprofile',
        name: 'storeprofile',
        component: () => import('../views/StoreProfileView.vue'),//店铺概况
        meta:{
          auth:true
        }
      },
      {
        path: 'goodsmanagement',
        name: 'goodsmanagement',
        component: () => import('../views/GoodsManagementView.vue'),//商品管理
        meta:{
          auth:true
        }
      },
      {
        path: 'goodsrelease',
        name: 'goodsrelease',
        component: () => import('../views/GoodsReleaseView.vue'),//发布商品
        meta:{
          auth:true
        }
      },
      {
        path: 'goodsgroup',
        name: 'goodsgroup',
        component: () => import('../views/GoodsGroupView.vue'),//商品分组
        meta:{
          auth:true
        }
      },
      {
        path: 'goodsedit',
        name: 'goodsedit',
        component: () => import('../views/GoodsEditView.vue'),//编辑商品
        meta:{
          auth:true
        }
      },
      {
        path: 'ordersituation',
        name: 'ordersituation',
        component: () => import('../views/OrderSituationView.vue'),//订单概况
        meta:{
          auth:true
        }
      },
      {
        path: 'orderall',
        name: 'orderall',
        component: () => import('../views/OrderAllView.vue'),//所有订单
        meta:{
          auth:true
        }
      },
      {
        path: 'orderrefundrights',
        name: 'orderrefundrights',
        component: () => import('../views/OrderRefundRightsView.vue'),//退款维权
        meta:{
          auth:true
        }
      },
      {
        path: 'orderdetails',
        name: 'orderdetails',
        component: () => import('../views/OrderDetailsView.vue'),//订单详情
        meta:{
          auth:true
        }
      },
      {
        path: 'customermanagement',
        name: 'customermanagement',
        component: () => import('../views/CustomerManagementView.vue'),//客户管理
        meta:{
          auth:true
        }
      },
      {
        path: 'customeroperation',
        name: 'customeroperation',
        component: () => import('../views/CustomerOperationView.vue'),//客户运营
        meta:{
          auth:true
        }
      },
      {
        path: 'customermembers',
        name: 'customermembers',
        component: () => import('../views/CustomerMembersView.vue'),//会员管理
        meta:{
          auth:true
        }
      },
      {
        path: 'customermemberscard',
        name: 'customermemberscard',
        component: () => import('../views/CustomerMembersCardView.vue'),//会员卡
        meta:{
          auth:true
        }
      },
      {
        path: 'customercreatememberscard',
        name: 'customercreatememberscard',
        component: () => import('../views/CustomerCreateMembersCardView.vue'),//新建会员卡
        meta:{
          auth:true
        }
      },
      {
        path: 'setstore',
        name: 'setstore',
        component: () => import('../views/SetStoreView.vue'),//店铺信息
        meta:{
          auth:true
        }
      },
      {
        path: 'setemployees',
        name: 'setemployees',
        component: () => import('../views/SetEmployeesView.vue'),//员工管理
        meta:{
          auth:true
        }
      },
      // {
      //   path: 'setcontactus',
      //   name: 'setcontactus',
      //   component: () => import('../views/SetContactUsView.vue'),//联系我们（不要）
      //   meta:{
      //     auth:true
      //   }
      // },
      {
        path: 'dataprofile',
        name: 'dataprofile',
        component: () => import('../views/DataProfileView.vue'),//数据概况
        meta:{
          auth:true
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import('../views/NotFound.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to,from,next)=>{
//   const token = store.state.userStore.token;
//   console.log('访问路由就会调用:beforeEach');
//   if(to.meta.auth){
//     if(token){
//       next();
//     }else{
//       next('/login');
//     }
//   }else{
//     next();
//   }
// })

export default router